<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>

    <style>
      .container {
        display: flex;
        flex-wrap: wrap;
      }

      .container .item {
        --n: 7;
        --space: calc(100% - var(--n) * 50px);
        --h: calc(var(--space) / var(--n) / 2);
        margin: 10px var(--h);

        background: red;
        height: 50px;
        width: 50px;
      }
    </style>
  </head>

  <body>
    <div class="container">
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
      <div class="item"></div>
    </div>
  </body>
</html>
